<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>流程操作日志</title>
    <#include "/pubHeadStyle.html">
</head>
<body>
<div style="position: relative;height: 100%;">
    <div class="tablesize roles" style="position: absolute;top:0;right:0px;bottom: 0;left: 0px; padding: 10px">
        <table id="processInstanceLogTable" lay-filter="processInstanceLogTable"></table>
    </div>
</div>


<script type="text/html" id="bar">
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    <a class="layui-btn layui-btn-xs" lay-event="detail">明细</a>
</script>

<script>

    layui.config({
        base: serverPath.systemPath + staticPath.systemPath //静态资源所在路径
    }).extend({
        index: 'index' //主入口模块
    }).use(['index','table', 'layer', 'util', 'commons', 'setter', 'totalFilter', 'laydate', 'common'], function () {
        var table = layui.table;
        var layer = layui.layer;
        var util = layui.util;
        var laydate = layui.laydate;
        var $ = layui.$;
        var setter = layui.setter;
        var commons = layui.commons;
        var common = layui.common;
        var totalFilter = layui.totalFilter;

        var tableH = commons.tabHeight();
        commons.reflashDate({startName: '#createTime', endName: '#endCreateTime'});

        var runId = '${runId}';

        //第一个实例
        table.render({
            elem: '#processInstanceLogTable'
            , cellMinWidth: 70
            , title: '流程操作日志'
            , height: tableH
            , url: serverPath.workflowPath + setter.workflowLinkPath + 'bpmRunLog/list'
            , where: {runId: runId}
            , method: 'post'
            , page: true
            , cols: [[
                {type: 'checkbox', fixed: 'left'}
                , {
                    field: 'processSubject',
                    title: '流程标题',
                    sort: true,
                    minWidth: 330,
                    align: 'center',
                    templet: function (d){
                        if(d.operatorType == 3) {
                            return '<div>'+d.processSubject+'</div>';
                        }else{
                            return '<div lay-event="get" style="cursor: pointer;color:#1E9FFF ;" >'+d.processSubject+'</div>';
                        }
                    }
                }
                , {field: 'userName', title: '用户名称', sort: true, minWidth: 60,align: 'center'}
                , {
                    field: 'createTime', title: '操作时间', minWidth: 200,sort: true, align: 'center', templet: function (d) {
                        if (d.createTime == undefined) {
                            return "";
                        } else {
                            return util.toDateString(d.createTime, "yyyy-MM-dd HH:mm:ss");
                        }
                    }
                }
                , {
                    field: 'operatorType', title: '操作类型', sort: true,minWidth: 160, align: 'center', templet: function (d) {
                        if (d.operatorType == undefined) {
                            return "";
                        }
                        if (d.operatorType == 0) {
                            return '<span style="color: #15cc08;">启动流程</span>';
                        }
                        if (d.operatorType == 1) {
                            return '<span style="color: #15cc08;">交办</span>';
                        }
                        if (d.operatorType == 2) {
                            return '<span style="color: #cc0c00;">撤销</span>';
                        }
                        if (d.operatorType == 3) {
                            return '<span style="color: #cc0c00;">删除流程实例</span>';
                        }
                        if (d.operatorType == 4) {
                            return '<span style="color: #15cc08;">同意(投票)</span>';
                        }
                        if (d.operatorType == 5) {
                            return '<span style="color: #cc0c00;">反对(投票)</span>';
                        }
                        if (d.operatorType == 6) {
                            return '<span style="color: #15cc08;">弃权(投票)</span>';
                        }
                        if (d.operatorType == 7) {
                            return '<span style="color: #15cc08;">补签</span>';
                        }
                        if (d.operatorType == 8) {
                            return '<span style="color: #cc0c00;">驳回</span>';
                        }
                        if (d.operatorType == 9) {
                            return '<span style="color: #cc0c00;">驳回到发起人</span>';
                        }
                        if (d.operatorType == 10) {
                            return '<span style="color: #cc0c00;">删除任务</span>';
                        }
                        if (d.operatorType == 11) {
                            return '<span style="color: #15cc08;">代理任务</span>';
                        }
                        if (d.operatorType == 13) {
                            return '<span style="color: #15cc08;">锁定任务</span>';
                        }
                        if (d.operatorType == 14) {
                            return '<span style="color: #15cc08;">任务解锁</span>';
                        }
                        if (d.operatorType == 15) {
                            return '<span style="color: #15cc08;">添加意见</span>';
                        }
                        if (d.operatorType == 16) {
                            return '<span style="color: #15cc08;">任务指派</span>';
                        }
                        if (d.operatorType == 17) {
                            return '<span style="color: #15cc08;">设定所有人</span>';
                        }
                        if (d.operatorType == 18) {
                            return '<span style="color: #15cc08;">结束任务</span>';
                        }
                        if (d.operatorType == 19) {
                            return '<span style="color: #15cc08;">更改执行路径</span>';
                        }
                        if (d.operatorType == 20) {
                            return '<span style="color: #15cc08;">收回任务</span>';
                        }
                        if (d.operatorType == 21) {
                            return '<span style="color: #15cc08;">结束流程实例</span>';
                        }
                        if (d.operatorType == 22) {
                            return '<span style="color: #15cc08;">保存流程草稿</span>';
                        }
                        if (d.operatorType == 23) {
                            return '<span style="color: #cc0c00;">删除流程草稿</span>';
                        }
                        if (d.operatorType == 24) {
                            return '<span style="color: #15cc08;">办结转发</span>';
                        }
                        if (d.operatorType == 25) {
                            return '<span style="color: #cc0c00;">追回</span>';
                        }
                        if (d.operatorType == 26) {
                            return '<span style="color: #15cc08;">任务交接</span>';
                        }
                    }
                }
                , {field: 'memo', title: '备注', sort: true,minWidth: 330, align: 'center'}
                , {fixed: 'right', title: '管理', toolbar: '#bar', width: 150, align: 'center'}
            ]]
        });
        totalFilter.init('processInstanceLogTable');

        //监听排序，实现后台排序
        table.on('sort(processInstanceLogTable)', function(obj){
            table.reload('processInstanceLogTable', { //testTable是表格容器id
                where: {
                    orderField: obj.field //排序字段
                    ,orderSeq: obj.type //排序方式
                }
            });
        });
        //监听行工具事件
        table.on('tool(processInstanceLogTable)', function (obj) {
            var data = obj.data;
            var runId = data.runId;
            switch (obj.event) {
                case 'del':
                    layer.confirm("确定删除当前数据吗？", {title: '删除确认'}, function (index) {
                        $.ajax({
                            url: serverPath.workflowPath + setter.workflowLinkPath + "bpmRunLog/del?id=" + data.id,
                            type: 'GET',
                            dataType: 'json',
                            data: {cascade: false},
                            success: function (result) {
                                if(common.filterRecord(result)){
                                    layer.alert(result.msg,function(){
                                        layer.closeAll();
                                        table.reload('processInstanceLogTable', {
                                            page: {
                                                curr: 1
                                            }
                                        });
                                    });
                                }else{
                                    layer.alert(result.msg);
                                }
                            }
                        });
                    });
                    break;
                case 'detail':
                    parent.layer.open({
                        type: 2,
                        title: "流程明细",
                        area: ['1000px', '400px'],
                        content:serverPath.workflowPath + setter.workflowLinkPath + 'bpmRunLog/view/get?id=' + data.id
                    });
                    break;
                case 'get':
                    window.open(serverPath.workflowPath + setter.workflowLinkPath + 'processRun/view/get?runId=' + runId);
                    break;
            }
        });
    });

</script>
</body>
</html>
